<script src="Libraries/js/js.js"></script>
<script type="text/javascript" src="Libraries/js/jquery.min.js"></script>
<script type="text/javascript" src="Libraries/js/jquery.datepick.js"></script>
<script type="text/javascript" src="Libraries/nicEdit/nicEdit.js"></script>
<script type="text/javascript">
	//bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });
	//bkLib.onDomLoaded(function() { nicEditors.findEditor('txtnoidung')});
	//var area1;
	bkLib.onDomLoaded(function() { var area1 = new nicEditor({fullPanel : true}).panelInstance('txtnoidung',{hasPanel : true}); });

	


   	
   	function checkChonNhomTH(){
		if (document.capnhatnhomth.rdomanhomth.length > 0){
			for (var i=0; i<document.capnhatnhomth.rdomanhomth.length; i++){
				
				var isOk = false;
				if ( document.capnhatnhomth.rdomanhomth[i].checked == true){
					isOk = true;
					
					break;   
				}
				
			}
			if (isOk==false){
				alert("Xin chọn nhóm thực hành!");
				return false;
			}
		}
		else {
			if ( document.capnhatnhomth.rdomanhomth.checked == true){
				alert("Xin chọn nhóm thực hành!"); 
				return false;  
			}
		}
		return true;
	}
	
	function getValueNhomTH(id){
		document.capnhatnhomth.btnsuanhomth.disabled = false;
		document.capnhatnhomth.btnxoanhomth.disabled = false;
		document.capnhatnhomth.btnthemnhomth.disabled = true;
		document.capnhatnhomth.txtmanhomth.value=document.getElementById("manhomth" + id).innerHTML;
		
		document.capnhatnhomth.txtsiso.value=document.getElementById("siso" + id).innerHTML;
		document.capnhatnhomth.txtmaso.value=document.getElementById("maso" + id).innerHTML;
		document.capnhatnhomth.txttencb.value=document.getElementById("tencb" + id).innerHTML;
		
		for(var i=0;i<document.capnhatnhomth.cboloainhomth.length;i++){
			if(document.capnhatnhomth.cboloainhomth[i].value==document.getElementById("maloai" + id).innerHTML){
				document.capnhatnhomth.cboloainhomth.selectedIndex=i;
				break;
			}
		}
		
	}
	function getValueLichTH(id){
		document.capnhatnhomth.btnsualichth.disabled = false;
		document.capnhatnhomth.btnxoalichth.disabled = false;
		document.capnhatnhomth.btnthemlichth.disabled = true;
		/*document.capnhatlichth.txtmanhomth.value=document.getElementById("manhomth" + id).innerHTML;
		
		document.capnhatlichth.txtsiso.value=document.getElementById("siso" + id).innerHTML;
		document.capnhatlichth.txtmaso.value=document.getElementById("maso" + id).innerHTML;*/
		
		
		for(var i=0;i<document.capnhatnhomth.cbotuan.length;i++){
			if(document.capnhatnhomth.cbotuan[i].value==document.getElementById("tuan" + id).innerHTML){
				document.capnhatnhomth.cbotuan.selectedIndex=i;
				break;
			}
		}
		for(var i=0;i<document.capnhatnhomth.cbothu.length;i++){
			if(document.capnhatnhomth.cbothu[i].value==document.getElementById("thu" + id).innerHTML){
				document.capnhatnhomth.cbothu.selectedIndex=i;
				break;
			}
		}
		for(var i=0;i<document.capnhatnhomth.cbotietbd.length;i++){
			if(document.capnhatnhomth.cbotietbd[i].value==document.getElementById("tietbd" + id).innerHTML){
				document.capnhatnhomth.cbotietbd.selectedIndex=i;
				break;
			}
		}
		for(var i=0;i<document.capnhatnhomth.cbosotiet.length;i++){
			if(document.capnhatnhomth.cbosotiet[i].value==document.getElementById("sotiet" + id).innerHTML){
				document.capnhatnhomth.cbosotiet.selectedIndex=i;
				break;
			}
		}
		document.capnhatnhomth.txtmaphong.value=document.getElementById("maphong" + id).innerHTML;
	}
	function checkValueNhomTH(){
		if (document.capnhatnhomth.cbonamhoc.selectedIndex == 0){
			alert("Xin vui lòng chọn năm học!");
			return false;
		}
		if (document.capnhatnhomth.cbohocki.selectedIndex == 0){
			alert("Xin vui lòng chọn học kì!");
			return false;
		}
		if (document.capnhatnhomth.cbohp.selectedIndex == 0){
			alert("Xin vui lòng chọn học phần!");
			return false;
		}
		if (document.capnhatnhomth.cbolophp.selectedIndex == 0){
			alert("Xin vui lòng chọn lớp học phần!");
			return false;
		}
		if (document.capnhatnhomth.txtmanhomth.value == ""){
			alert("Xin vui lòng nhấn Tạo mới để tạo nhóm thực hành!");
			return false;
		}
		if (isDigit(document.capnhatnhomth.txtsiso.value) == false){
			alert("Sĩ số là một số nguyên!");
			return false;
		}
		if (document.capnhatnhomth.cboloainhomth.selectedIndex == 0){
			alert("Xin vui lòng chọn loại nhóm thực hành!");
			return false;
		}
		
		if (document.capnhatnhomth.txtmaso.value == "" || document.capnhatnhomth.txttencb.value == ""){
			alert("Xin vui lòng nhập mã số cán bộ!");
			return false;
		}
		
		return true;
	}
	function checkValueLichTH(){
		if (document.capnhatnhomth.cbotuan.selectedIndex == 0){
			alert("Xin vui lòng chọn tuần!");
			return false;
		}
		if (document.capnhatnhomth.cbothu.selectedIndex == 0){
			alert("Xin vui lòng chọn thứ!");
			return false;
		}
		if (document.capnhatnhomth.cbotietbd.selectedIndex == 0){
			alert("Xin vui lòng chọn tiết bắt đầu!");
			return false;
		}
		if (document.capnhatnhomth.cbosotiet.selectedIndex == 0){
			alert("Xin vui lòng chọn số tiết!");
			return false;
		}
		if (document.capnhatnhomth.txtmaphong.value == ""){
			alert("Xin vui lòng nhập mã phòng!");
			document.capnhatnhomth.txtmaphong.focus();
			return false;
		}
		
		return true;
	}
	function checkFieldGhiXNCuaSV(){
		
		if (document.capnhatnhomth.rdochon.checked == false)
		{
			alert("Xin chọn lớp học phần cần ghi nhật kí!");
			return false;
		}
		else{
			if (document.capnhatnhomth.txtxacnhancuasv.value == ""){
				alert("Xin vui lòng nhập thông tin vao mục xác nhận của sinh viên!");
				return false;
				
			}
		}
		/*if (var i=0; i<document.capnhatnhomth.rdochon.length > 1)
			for (var i=0; i<document.capnhatnhomth.rdochon.length; i++){
				
				var isOk = false;
				if ( document.capnhatnhomth.rdochon[i].checked == true){
					isOk = true;
					//document.capnhatnhomth.rdomalophp[i].checked = false;
					break;   
				}
				//return isOK;
			}
			if (isOk==false){
				alert("Xin chọn lớp học phần cần ghi nhật kí!");
				return false;
			}
		else{
		
			if (document.capnhatnhomth.rdochon.checked == false)
			{
				alert("Xin chọn lớp học phần cần ghi nhật kí!");
				return false;
			}
		}*/
		/*if (document.capnhatnhomth.txtxacnhancuasv.value = ""){
			alert("Xin vui lòng nhập thông tin vao mục xác nhận của sinh viên!");
			return false;
			
		}
		/*else{
			if (var i=0; i<document.capnhatnhomth.rdochon.length > 1)
				for (var i=0; i<document.capnhatnhomth.rdochon.length; i++){
					
					var isOk = false;
					if ( document.capnhatnhomth.rdochon[i].checked == true){
						isOk = true;
						//document.capnhatnhomth.rdomalophp[i].checked = false;
						break;   
					}
					//return isOK;
				}
				if (isOk==false){
					alert("Xin chọn lớp học phần cần ghi nhật kí!");
					return false;
				}
			else{
			
				if (document.capnhatnhomth.rdochon.checked == false)
				{
					alert("Xin chọn lớp học phần cần ghi nhật kí!");
					return false;
				}
			}
		} */
		return true;
	}
    function confirmDelete(){
         if (confirm("Bạn có chắc muốn xóa nhóm thực hành này không?")){
            return true;
         }
         return false;
    }
    function confirmUpdate(){
         if (confirm("Bạn có chắc muốn sửa thông tin của nhóm thực hành này không?")){
            return checkValueNhomTH();
         }
         return false;
    }
	function confirmDeleteLichTH(){
         if (confirm("Bạn có chắc muốn xóa lịch thực hành này không?")){
            return true;
         }
         return false;
    }
    function confirmUpdateLichTH(){
         if (confirm("Bạn có chắc muốn sửa lịch thực hành này không?")){
            return checkValueLichTH();
         }
         return false;
    }
	function checkFieldGiaiTrinh(){	
		
		if (document.capnhatnhomth.txtgiaitrinh.value.length<=0){
			alert("Xin vui lòng nhập thông tin vào mục Ghi nhận/Giải trình/Đề nghị!");
			return false;			
		}
		return true;
	
    }
    function checkFieldGhiNXCuaBM(){				
		if (document.capnhatnhomth.txtnhanxetcuabm.value == ""){
			alert("Xin vui lòng nhập thông tin vào mục nhận xét của Bộ môn!");
			return false;			
		}
		return true;
	
    }
	function checkFieldGhiNXCuaDV(){				
		if (document.capnhatnhomth.txtnhanxetcuadv.value == ""){
			alert("Xin vui lòng nhập thông tin vào mục nhận xét của Đơn vị!");
			return false;			
		}
		return true;
    }
	function empty(){
	   //alert()
	   document.capnhatnhomth.btnsualichth.disabled = true;
		document.capnhatnhomth.btnxoalichth.disabled = true;
		document.capnhatnhomth.btnthemlichth.disabled = false;
		document.capnhatnhomth.cbotuan.selectedIndex = 0;
		document.capnhatnhomth.cbothu.selectedIndex = 0;
		document.capnhatnhomth.cbotietbd.selectedIndex = 0;
		document.capnhatnhomth.cbosotiet.selectedIndex = 0;
		document.capnhatnhomth.txtmaphong.value="";
		//document.capnhatnhomth.cbohinhthucday.selectedIndex = 0;
		//nicEditors.findEditor('txtnoidung').setContent("");
		//document.capnhatnhomth.txtngay.value="";
		//document.capnhatnhomth.txtsosvhiendien.value="";
		//document.capnhatnhomth.txtxacnhancuasv.value="";
		//document.capnhatnhomth.rdochon.checked = false;
		//alert(document.capnhatnhomth.rdochon.length);
		//document.capnhatnhomth.btnthemnkct.disabled = false;
        //document.capnhatnhomth.btnsuankct.disabled = false;
        //document.capnhatnhomth.btnxoankct.disabled = false;
		if (document.capnhatnhomth.rdochon.length > 0){
			for (var i=0; i<document.capnhatnhomth.rdochon.length; i++){
				
				
				if ( document.capnhatnhomth.rdochon[i].checked == true){
					
					document.capnhatnhomth.rdochon[i].checked = false;
					break;   
				}
				
			}
		}
		else{
			document.capnhatnhomth.rdochon.checked = false;
		}
	}
	$(function() {
	//$('#popupDatepicker').datepick();
	$('#inlineDatepicker').datepick({onSelect: showDate});
	$('#popupDatepicker').datepick();
	$('#popupDatepicker2').datepick();
});
 
function showDate(date) {
	alert('The date chosen is ' + date);
}
function taoMaLopMaNhomTH(malophp)
{ 
    //alert("?namhoc="+namhoc+"&hocki="+hocki);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	 	alert ("Browser does not support HTTP Request")
	 	return
	}
	var url="xuliajax.php"
	url=url+"?func=taomanhomth&malophp="+malophp;
	url=url+"&sid="+Math.random()
    //alert(url);
	xmlHttp.onreadystatechange=stateChangedFortaoMaLopMaNhomTH
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChangedFortaoMaLopMaNhomTH() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	 { 
	   var result = xmlHttp.responseText;
       if(result != "")
       {
            var myArr = result.split("|");
            document.capnhatnhomth.txtmanhomth.value =  myArr[0];
            document.capnhatnhomth.txtsiso.value =  "";
			document.capnhatnhomth.cboloainhomth.selectedIndex =  0;
			document.capnhatnhomth.txtmaso.value =  "";
			document.capnhatnhomth.txttencb.value =  "";
			document.capnhatnhomth.btnthemnhomth.disabled = false;
			document.capnhatnhomth.btnsuanhomth.disabled = true;
           document.capnhatnhomth.btnxoanhomth.disabled = true;
		   if (document.capnhatnhomth.rdomanhomth.length > 0){
				for (var i=0; i<document.capnhatnhomth.rdomanhomth.length; i++){
					
					
					if ( document.capnhatnhomth.rdomanhomth[i].checked == true){
						
						document.capnhatnhomth.rdomanhomth[i].checked = false;
						break;   
					}
					
				}
			}
			else{
				document.capnhatnhomth.rdomanhomth.checked = false;
			}
        }

	 	
	 } 
}
 
</script>
<?php
    include_once('Configs/database.php');
	include_once('Models/HocPhan.php');
	include_once('Configs/paging.php');
    include_once('Models/HocKiNamHoc.php');
    include_once('Models/HPMoVaoHKNH.php');
    include_once('Models/LopHocPhan.php');
    include_once('Models/Khoa.php');
	 include_once('Models/NhatKi.php');
    include_once('Models/CanBoGiangDay.php');
	include_once('Models/LoaiNhomTH.php');
	include_once('Models/NhomThucHanh.php');
	include_once('Models/LichThucHanh.php');
    
?>
<link href="Libraries/css/jquery.datepick.css" rel="stylesheet" type="text/css"></head>
<form name="capnhatnhomth" method="POST">
<table align="center" class="font" width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td class=main_1><img border="0" src="Libraries/images/tbl_left.gif" width="10" height="25" /></td>
    <td align=center class=main_1>Cập Nhật Nhóm Thực Hành </td>
    <td class=main_1><p align="right"><img border="0" src="Libraries/images/tbl_right.gif" width="10" height="25" /></p></td>
  </tr>
  <tr >
    <td class="border_1" colspan="3" valign="top"><table width="100%" border="0" align="center"  >
                <tr>
                    <td width="130%" >&nbsp;</td>
                </tr>
                <tr>
                  <td align="center"><table border="0">
                      <tr>
                        <td>Năm Học</td>
                        <td>
							<select name="cbonamhoc" onchange="document.capnhatnhomth.cbohocki.selectedIndex=0;">
                          		<option value=" "></option>
                          			<?php
										$hknh = new HocKiNamHoc();
                                		$result = $hknh->dsNamHoc();
                                		while ($rows=mysql_fetch_array($result)){
                                    		echo "<option value='".$rows['namhoc']."'";				
				                    		echo ">".$rows['namhoc']."</option>";
                                		}
                                		if (isset($_POST['cbonamhoc'])){
                                    		echo "<script language=\"javascript\">for(var i=0;i<document.capnhatnhomth.cbonamhoc.length;i++){if(document.capnhatnhomth.cbonamhoc[i].value=='$namhoc'){document.capnhatnhomth.cbonamhoc.selectedIndex=i;break;}}</script>";
                                		}
                                	?>
                        	</select>						</td>
                        <td>Học Kì</td>
                        <td>
							<select name="cbohocki"  onchange="document.capnhatnhomth.submit();">
                          		<option value="0"></option>
                          		<option value="1" <?php if ($_POST['cbohocki']==1) echo "selected='selected'"; ?>>1</option>
                          		<option value="2" <?php if ($_POST['cbohocki']==2) echo "selected='selected'"; ?>>2</option>
                          		<option value="3" <?php if ($_POST['cbohocki']==3) echo "selected='selected'"; ?>>Hè</option>
                        	</select></td>
                        <td>Học Phần </td>
                        <td><select name="cbohp" onchange="document.capnhatnhomth.submit();">
                          <option value=" "></option>
                          <?php
							$hphknh = new HPMoVaoHKNH();
							$hphknh->setHocKi($hocki);
							$hphknh->setNamHoc($namhoc);
							
							
							//$result = $hphknh->dsHocPhanMoVaoHKNH();
							$result = $hphknh->dsHocPhanDayVaoHKNHCuaCBGD($_SESSION['nmaso']);
							echo $hphknh->getQuery();
							while ($rows = mysql_fetch_array($result)){
								echo "<option value='".$rows['mahp']."'>".$rows['tenhp']."</option>";
							}
                            
						?>
                        </select></td>
                      </tr>
                      <tr>
                        <td>Kí Hiệu </td>
                        <td>
						<select name="cbolophp" onchange="document.capnhatnhomth.submit();">
                          <option value=" "></option>
                          <?php
							if (isset($_POST['cbohp'])){
								 echo "<script language=\"javascript\">for(var i=0;i<document.capnhatnhomth.cbohp.length;i++){if(document.capnhatnhomth.cbohp[i].value=='$mahp'){document.capnhatnhomth.cbohp.selectedIndex=i;break;}}</script>";
								$lophp = new LopHocPhan();
								$lophp->setNamHoc($namhoc);
								$lophp->setHocKi($hocki);
								$lophp->setMaHP($mahp);
								$lophp->setMaSo($_SESSION['nmaso']);
								$result = $lophp->dsLopHPCuaHPMoTrongHKNHCuaCBGD();
								//$result = $lophp->dsLopHPMoTrongHKNHCuaHP();
								while ($rows=mysql_fetch_array($result)){
									echo "<option value='".$rows['malophp']."'";				
									echo ">".$rows['kihieu']."</option>";
								}
								if (isset($_POST['cbolophp'])){
									echo "<script language=\"javascript\">for(var i=0;i<document.capnhatnhomth.cbolophp.length;i++){if(document.capnhatnhomth.cbolophp[i].value=='$malophp'){document.capnhatnhomth.cbolophp.selectedIndex=i;break;}}</script>";
								}
							
							}             
						  ?>
                        </select>						</td>
                        <td>Mã Nhóm </td>
                        <td><input name="txtmanhomth" type="text" id="txtmanhomth" size="20" readonly="true" style="background:#CCCCCC" value="<?php echo trim($manhomth)?>"/></td>
                        <td>Sĩ Số </td>
                        <td><input name="txtsiso" type="text" id="txtsiso" size="5"  value="<?php echo trim($siso)?>"/></td>
                      </tr>
                      <tr>
                        <td>Loại Nhóm </td>
                        <td>
							<select name="cboloainhomth" id="cboloainhomth">
								<option value=""></option>
								<?php
								$loainhomth = new LoaiNhomTH();
								$loainhomth->setQuery("select distinct maloai,mota from LoaiNhomTH order by mota asc");
								//$result = $loainhomth->dsLoaiNhomTH();
								$result = $loainhomth->fetchAll();
								while ($rows=mysql_fetch_array($result)){
									echo "<option value='".$rows['maloai']."'";				
									echo ">Loai ".$rows['maloai'].": ".$rows['mota']."</option>";
								}
								if (isset($_POST['cbolophp'])){
									echo "<script language=\"javascript\">for(var i=0;i<document.capnhatnhomth.cboloainhomth.length;i++){if(document.capnhatnhomth.cboloainhomth[i].value=='$maloai'){document.capnhatnhomth.cboloainhomth.selectedIndex=i;break;}}</script>";
								}
								?>
						  </select>						</td>
                        <td>MSCB</td>
                        <td><input name="txtmaso" type="text" size="16"  value="<?php echo trim($maso)?>" onkeyup="showTenCB(this.value);"/></td>
                        <td>Tên CB </td>
                        <td><table border="0">
                          <tr>
                            <td><div id="tencb">
                                <input name="txttencb" type="text" size="30"  value="<?php echo trim($tencb)?>" readonly="true" style="background:#CCCCCC" />
                                                        </div></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table>				</td>
               </tr>
                <tr>
                  <td align="center"><input name="btntaomoinhomth" type="button" class="button_1" id="btntaomoinhomth" value="Tạo mới" onclick="taoMaLopMaNhomTH(document.capnhatnhomth.cbolophp.value);"/>
                    <input name="btnthemnhomth" type="submit" class="button_1" id="btnthemnhomth" onclick="return checkValueNhomTH();" value="Thêm"/>
                    <input name="btnsuanhomth" type="submit" disabled="disabled" class="button_1" id="btnsuanhomth" onclick="return confirmUpdate();" value="Sửa"/>
                    <input name="btnxoanhomth" type="submit" disabled="disabled" class="button_1" id="btnxoanhomth" onclick="return confirmDelete();" value="Xóa"/></td>
                </tr>
              
               <tr>
                 <td align="center">
                 <?php
                   //echo "mahp:".$mahp;
                    if (trim(strlen($malophp)) > 0 || (trim(strlen($malophp)) > 0 && isset($_POST['btnthemnhomth'])) || (trim(strlen($malophp)) > 0 && isset($_POST['btnsuanhomth'])) || (trim(strlen($malophp)) > 0 && isset($_POST['btnxoanhomth']))){
                       $lophp = new LopHocPhan();
                        $lophp->setMaLopHP($malophp);
						
                        $result = $lophp->dsNhomThucHanh();
						//echo $thoigianapdung;
                        $i = 0;
                        $numRecord = mysql_num_rows($result);
                        
                          echo "<table width='800' border='0'>";
                           echo "<tr>";
                             echo "<td><div class='panel_cn' style=' border:1 #0099FF;'>";
                               echo "<fieldset>";
                               echo "<legend>Danh sách nhóm thực hành </legend>";
                                 echo "<table width='800' class='border_1'  id='tbmain' cellpadding='0' cellspacing='0'>";
                                     echo "<tr>";
                                       echo "<td align='center' width='40' class='main_3' >STT</td>";
                                       echo "<td align='center' class='main_3' width='70'>Mã Nhóm</td>";
									   echo "<td align='center' class='main_3' width='60'>Sĩ Số </td>";
                                       echo "<td align='center' class='main_3' width='40'>Loại nhóm</td>";
                                       echo "<td align='center' class='main_3' width='60'>MSSB</td>";
                                       echo "<td align='center' class='main_3' width='180'>Tên Cán Bộ</td>";
                                       
                                       //echo "<td align='center' class='main_3' width='120'>Tuần Học</td>";
                                       echo "<td align='center' class='main_3' width='40'>Chọn</td>";
                                     echo "</tr>";
						 
     	                      if ($numRecord > 0){
                                    while ($rows = mysql_fetch_array($result))
									{
                                        $i++;
                                        $c = 2-$i%2;
										/*$db = new database();
										$db->setQuery("select distinct mota from LoaiNhomTH where maloai =".$rows['maloai']."");
										$resultmota = $db->fetchAll();
										$rowsmota = mysql_fetch_array($resultmota); 
										$mota = $rowsmota['mota'];*/
                                   $cbgd = new CanBoGiangDay();
								   $cbgd->setMaSo($rows['maso']);
								   $resultcb = $cbgd->thongTinCanBoGiangDay();
                               		$rowscb= mysql_fetch_array($resultcb);
									$tencb = $rowscb['hoten'];
									
									
                                     echo "<tr>";
                                       echo "<td align='center' class='level_1_$c' >".$i."</td>";
                                       echo "<td align='center' class='level_1_$c'><div id='manhomth$i'>".$rows['manhomth']."</div></td>";
									   echo "<td align='center' class='level_1_$c'><div id='siso$i'>".$rows['siso']."</div></td>";
                                       echo "<td align='center'  class='level_1_$c'><div id='maloai$i'>".$rows['maloai']."</div></td>";
                                       echo "<td align='center'  class='level_1_$c'><div id='maso$i'>".$rows['maso']."</div></td>";
                                       echo "<td align='center' class='level_1_$c'><div id='tencb$i'>".$tencb."</div></td>";
                                       
                                       //echo "<td align='center'  class='level_1_$c'>".$rows['tuanhoc']."</td>";
                                       echo "<td align='center'  class='level_1_$c'><input type='radio' name='rdomanhomth' value='$i'  onclick='getValueNhomTH(this.value);'/></td>";
                                       
                                     echo "</tr>";
									 
                                    }
									echo "<tr>";
                                        echo "<td align='center' colspan='8'><input name= 'btnxeptkb' type='submit' class='button_1' value='Xếp lịch thực hành' onClick='return checkChonNhomTH();'/></td>";
                                       
                                       
                                     echo "</tr>";
                                
                                }
                                else{
                                     echo "<tr>";
                                       echo "<td align='center' class='level_1_$c' colspan='8'>Không có nhóm thực hành nào.</td>";
                                      
                                     echo "</tr>";
                                }
                               echo "</table>";
                               echo "</fieldset>";
                             echo "</div></td>";
                           echo "</tr>";
                         echo "</table> ";
                        
                        
                    }
                    if ((trim(strlen($malophp)) > 0 && isset($_POST['btnxeptkb'])) || (trim(strlen($malophp)) > 0 && isset($_POST['btnthemlichth'])) || (trim(strlen($malophp)) > 0 && isset($_POST['btnsualichth'])) || (trim(strlen($malophp)) > 0 && isset($_POST['btnxoalichth']))){
                        echo "<script language=\"javascript\">";
                		
					
							
							//echo "document.capnhatnhomth.txtmanhomth.value = '$manhomth';";
							//echo "document.capnhatlophp.txtkihieu.value = '$kihieu';";
						  	//echo "document.capnhatnhomth.txtsiso.value = '$siso';";
							//echo "document.capnhatlophp.txttuanhoc.value = '$tuanhoc';";
							//echo "document.capnhatnhomth.txtmaso.value = '$maso';";
							//echo "document.capnhatnhomth.txttencb.value = '$tencb';";
						 echo "for (var i = 0; i< document.capnhatnhomth.cboloainhomth.length; i++){";
                        echo "if (document.capnhatnhomth.cboloainhomth[i].value == '$maloai'){";
                        echo "document.capnhatnhomth.cboloainhomth.selectedIndex=i;";
                        echo "break;";
                        echo "}";
                        echo "}";	
                        /*echo "for (var i = 0; i< document.capnhatnhomth.rdomalophp.length; i++){";
                        echo "if (document.capnhatnhomth.rdomalophp[i].value == '$malophp'){";
                        echo "document.capnhatnhomth.rdomalophp[i].checked = true;";
                        echo "break;";
                        echo "}";
                        echo "}";*/
                      
                        echo "</script>";
                       
                      
                 ?>                  
                 <table width="800" border="0">
                   <tr>
                     <td width="99%"><div class="panel_cn" style=" border:1 #0099FF;">
                       <fieldset>
                         <legend>Lịch Thực Hành </legend>
                         <table width="800" class="border_1"  id="tbmain" cellpadding="0" cellspacing="0">
						 	 <tr>
								<td align="center" width="14" class="main_3" >Tuần</td>
								<td align="center" width="14" class="main_3" >Thứ</td>
								<td align="center" class="main_3" width="60">Ti&#7871;t B&#272; </td>
								<td align="center" class="main_3" width="60">S&#7889; Ti&#7871;t </td>
								<td align="center" class="main_3" width="60">Ph&ograve;ng</td>
								<td align="center" class="main_3" width="50">Ch&#7885;n</td>
							  </tr>
                          <?php
								 $lichth = new LichThucHanh();
								 $lichth->setMaNhomTH($manhomth);
								 $resultlichth = $lichth->lichThucHanhNhomThucHanh();
								 $numlichth = mysql_num_rows($resultlichth);
								 if ($numlichth > 0){ $i = 0;
							
											
									  while ($rowslichth = mysql_fetch_array($resultlichth)){
											$i++;
											$ci = 2 - $i % 2;
										   echo "<tr>";
										   		echo "<td align='center' class='level_1_$ci'><div id='tuan$i'>".$rowslichth['tuan']."</div></td>";
											   echo "<td align='center' class='level_1_$ci'><div id='thu$i'>".$rowslichth['thu']."</div></td>";
											   echo "<td width='60' align='center' class='level_1_$ci'><div id='tietbd$i'>".$rowslichth['tietbd']."</div></td>";
											   echo "<td width='60' align='center' class='level_1_$ci'><div id='sotiet$i'>".$rowslichth['sotiet']."</div></td>";
											   echo "<td width='60' align='center' class='level_1_$ci'><div id='maphong$i'>".$rowslichth['maphong']."</div></td>";
											   echo "<td align='center' class='level_1_$ci'><input type='radio' name='rdochon' value='$i'  onclick='getValueLichTH(this.value);'></td>";
										  echo "</tr>";
									  }
								}
								else{
									echo "<tr>";
										echo "<td width='30' align='center' colspan='5'><b>Chưa sắp Thời khóa biểu</b></td>";
																	
																	
									echo "</tr>";
								}
							
							
						  ?>
						  <tr>
                                
                                <td align="center" class="main_3"><select name="cbotuan">
                                  <option value="0" <?php if ($_POST['cbotuan']==0) echo "selected='selected'"; ?>></option>
                                  <option value="1" <?php if ($_POST['cbotuan']==1) echo "selected='selected'"; ?>>1</option>
                                  <option value="2" <?php if ($_POST['cbotuan']==2) echo "selected='selected'"; ?>>2</option>
                                  <option value="3" <?php if ($_POST['cbotuan']==3) echo "selected='selected'"; ?>>3</option>
                                  <option value="4" <?php if ($_POST['cbotuan']==4) echo "selected='selected'"; ?>>4</option>
                                  <option value="5" <?php if ($_POST['cbotuan']==5) echo "selected='selected'"; ?>>5</option>
                                  <option value="6" <?php if ($_POST['cbotuan']==6) echo "selected='selected'"; ?>>6</option>
                                  <option value="7" <?php if ($_POST['cbotuan']==7) echo "selected='selected'"; ?>>7</option>
                                  <option value="8" <?php if ($_POST['cbotuan']==8) echo "selected='selected'"; ?>>8</option>
                                  <option value="9" <?php if ($_POST['cbotuan']==9) echo "selected='selected'"; ?>>9</option>
                                  <option value="10" <?php if ($_POST['cbotuan']==10) echo "selected='selected'"; ?>>10</option>
                                  <option value="11" <?php if ($_POST['cbotuan']==11) echo "selected='selected'"; ?>>11</option>
                                  <option value="12" <?php if ($_POST['cbotuan']==12) echo "selected='selected'"; ?>>12</option>
                                  <option value="13" <?php if ($_POST['cbotuan']==12) echo "selected='selected'"; ?>>13</option>
                                  <option value="14" <?php if ($_POST['cbotuan']==14) echo "selected='selected'"; ?>>14</option>
                                  <option value="15" <?php if ($_POST['cbotuan']==15) echo "selected='selected'"; ?>>15</option>
                                  <option value="16" <?php if ($_POST['cbotuan']==16) echo "selected='selected'"; ?>>16</option>
                                  <option value="17" <?php if ($_POST['cbotuan']==17) echo "selected='selected'"; ?>>17</option>
                                  <option value="18" <?php if ($_POST['cbotuan']==18) echo "selected='selected'"; ?>>18</option>
                                  <option value="19" <?php if ($_POST['cbotuan']==19) echo "selected='selected'"; ?>>19</option>
                                  <option value="20" <?php if ($_POST['cbotuan']==20) echo "selected='selected'"; ?>>20</option>
                                </select></td>
                                
                                <td align="center" class="main_3"><select name="cbothu">
                                   <option value="0" <?php if ($_POST['cbothu']==0) echo "selected='selected'"; ?>></option>
                                  <option value="2" <?php if ($_POST['cbothu']==2) echo "selected='selected'"; ?>>2</option>
                                  <option value="3" <?php if ($_POST['cbothu']==3) echo "selected='selected'"; ?>>3</option>
                                  <option value="4" <?php if ($_POST['cbothu']==4) echo "selected='selected'"; ?>>4</option>
                                  <option value="5" <?php if ($_POST['cbothu']==5) echo "selected='selected'"; ?>>5</option>
                                  <option value="6" <?php if ($_POST['cbothu']==6) echo "selected='selected'"; ?>>6</option>
                                  <option value="7" <?php if ($_POST['cbothu']==7) echo "selected='selected'"; ?>>7</option>
                                   <option value="8" <?php if ($_POST['cbothu']==8) echo "selected='selected'"; ?>>CN</option>
                                </select></td>
                                
                                <td align="center" class="main_3"><select name="cbotietbd">
                                  <option value="0" <?php if ($_POST['cbotietbd']==0) echo "selected='selected'"; ?>></option>
                                  <option value="1" <?php if ($_POST['cbotietbd']==1) echo "selected='selected'"; ?>>1</option>
                                  <option value="2" <?php if ($_POST['cbotietbd']==2) echo "selected='selected'"; ?>>2</option>
                                  <option value="3" <?php if ($_POST['cbotietbd']==3) echo "selected='selected'"; ?>>3</option>
                                  <option value="4" <?php if ($_POST['cbotietbd']==4) echo "selected='selected'"; ?>>4</option>
                                  <option value="5" <?php if ($_POST['cbotietbd']==5) echo "selected='selected'"; ?>>5</option>
                                  <option value="6" <?php if ($_POST['cbotietbd']==6) echo "selected='selected'"; ?>>6</option>
                                  <option value="7" <?php if ($_POST['cbotietbd']==7) echo "selected='selected'"; ?>>7</option>
                                  <option value="8" <?php if ($_POST['cbotietbd']==8) echo "selected='selected'"; ?>>8</option>
                                  <option value="9" <?php if ($_POST['cbotietbd']==9) echo "selected='selected'"; ?>>9</option>
                                  <option value="10" <?php if ($_POST['cbotietbd']==10) echo "selected='selected'"; ?>>10</option>
                                </select></td>
                                
                                <td align="center" class="main_3"><select name="cbosotiet" onchange="xepPhong(document.capnhattkb.txtsiso.value,document.capnhattkb.cbothu.value,document.capnhattkb.cbotietbd.value,this.value);">
                                   <option value="0" <?php if ($_POST['cbosotiet']==0) echo "selected='selected'"; ?>></option>
                                  <option value="1" <?php if ($_POST['cbosotiet']==1) echo "selected='selected'"; ?>>1</option>
                                  <option value="2" <?php if ($_POST['cbosotiet']==2) echo "selected='selected'"; ?>>2</option>
                                  <option value="3" <?php if ($_POST['cbosotiet']==3) echo "selected='selected'"; ?>>3</option>
                                  <option value="4" <?php if ($_POST['cbosotiet']==4) echo "selected='selected'"; ?>>4</option>
                                  <option value="5" <?php if ($_POST['cbosotiet']==5) echo "selected='selected'"; ?>>5</option>
                                </select></td>
                                
                                <td align="center" class="main_3"><table border="0">
                                  <tr>
                                    <td><input name="txtmaphong" type="text" value="<?php echo $maphong?>" size="8"/></td>
                                  </tr>
                                </table></td>
								<td class="main_3">&nbsp;</td>
                              </tr>
							  
                          <tr>
                            <td colspan="9" align="center"><table width="100%" border="0" align="center">
                              

                              <tr>
                                <td colspan="10" align="center"><input name="btntaomoilichth" type="button" class="button_1" id="btntaomoilichth" value="Tạo mới" onclick="return empty();"/>
                                  <input name="btnthemlichth" type="submit" class="button_1" id="btnthemlichth" onclick="return checkValueLichTH();" value="Thêm"/>
                                  <input name="btnsualichth" type="submit" disabled="disabled" class="button_1" id="btnsualichth" onclick="return confirmUpdateLichTH();" value="Sửa"/>
                                  <input name="btnxoalichth" type="submit" disabled="disabled" class="button_1" id="btnxoalichth" onclick="return confirmDeleteLichTH();" value="Xóa"/></td>
                              </tr>
                            </table></td>
                          </tr>
                        </table>
                       </fieldset>
                     </div></td>
                   </tr>
                   </table>
                   <?php
				   }
				   ?>                 </td>
               </tr>
               
                
        </table>
       
           

    </td>
  </tr>
</table>
<br />



 

</form>
